package logic

import (
	"context"
	"user-profile/userProfilerpc/userProfilerpc"

	"user-profile/api/internal/svc"
	"user-profile/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserInfoAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoAddLogic {
	return &UserInfoAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserInfoAddLogic) UserInfoAdd(req *types.UserInfoAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.UserProFileRpc.UserInfoAdd(l.ctx, &userProfilerpc.UserInfoAddRequest{
		UserId:      int64(req.UserId),
		HeaderImage: req.HeaderImage,
		Name:        req.Name,
		Happy:       req.Happy,
		Sex:         req.Sex,
		Info:        req.Info,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "个人信息添加成功",
		Code:    200,
		Data:    add,
	}, nil
}
